/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2020年9月16日
 */
package com.massyframework.beanskin.web;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 提供对Http请求处理方法, 多个{@link HttpProcessor}可以组合迭代对请求进行处理
 * 
 * @author huangkh
 *
 */
public interface HttpProcessor {

	/**
     * 初始化
     * @param config {@link ServletConfig}
     * @throws ServletException 初始化阶段发生非预期的例外
     */
    void init(ServletConfig config) throws ServletException;

    /**
     * 处理Http请求，并填充Http响应
     * @param request {@link HttpServletResponse}, http请求
     * @param response {@link HttpServletResponse}, http响应
     * @return {@link boolean}, 返回<code>true</code>表示已处理该请求，否则返回<code>false</code>
     * @throws ServletException 请求处理阶段发生的非预期例外
     * @throws IOException io读写发生的非预期例外
     */
    boolean process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException;

    /**
     * 析构释放资源
     */
    void destroy();
}
